package gogs_hook

import "atomgit.com/openlinksaas-org/proto-gen-go.git/events/events_gogs"

type ReleaseHook struct {
	Action     string      `json:"action"`
	Release    *Release    `json:"release"`
	Repository *Repository `json:"repository"`
	Sender     *User       `json:"sender"`
}

func (item *ReleaseHook) ToProtoBuf() *events_gogs.ReleaseEvent {
	ret := &events_gogs.ReleaseEvent{
		Action:     item.Action,
		Release:    []*events_gogs.Release{},
		Repository: []*events_gogs.Repository{},
		Sender:     []*events_gogs.User{},
	}
	if item.Release != nil {
		ret.Release = append(ret.Release, item.Release.ToProtoBuf())
	}
	if item.Repository != nil {
		ret.Repository = append(ret.Repository, item.Repository.ToProtoBuf())
	}
	if item.Sender != nil {
		ret.Sender = append(ret.Sender, item.Sender.ToProtoBuf())
	}
	return ret
}
